package com.bwie.task;

import com.bwie.mapper.TbCouponMapper;
import com.bwie.pojo.TbCoupon;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;

/**
 * description:
 *
 * @Author zhaohaoyang
 * @Create 2025/7/15 15:52
 * @Version 1.0
 */
@Slf4j
public class CouponTask {

    @Autowired
    TbCouponMapper tbCouponMapper;
    @Scheduled(cron = "0 0/10 * * * ?") //每10分钟执行一次
    public void task(){
        List<TbCoupon> tbCoupons = tbCouponMapper.selectList(null);
        for (TbCoupon tbCoupon : tbCoupons) {
           // 神券套餐需要使用定时器每隔10分钟补充一下券（3分）
            tbCoupon.setCouponStatus(0);
            tbCouponMapper.updateById(tbCoupon);
        }
    }

}
